package com.eatme.web.sys.repository;

import com.eatme.web.sys.entity.SysUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface SysUserRepository extends JpaRepository<SysUser,Integer>, JpaSpecificationExecutor {

    SysUser findSysUserByUsername(String username);

    @Modifying
    @Query(value = "update Sys_User set status = 0 where id = :id",nativeQuery=true)
    int updateSysUserStatusById(@Param("id") Integer id);

    Boolean existsByUsername(String username);

    Boolean existsByTelephone(String telephone);

    Boolean existsByMail(String mail);

    List<SysUser> findAllByStatus(Integer status);
}
